package channelService

import (
	"gitee.com/fierce_wolf/go-fox-edge-channel-common/channelAPI"
	"go-fox-edge-channel-serial-analyzer/channelEntity"
)

var (
	service *channelService
	report  *reportService
)

func init() {
	// 初始化对象
	service = &channelService{}
	report = &reportService{}
}

func BindChannelAPI() {
	// 绑定已经实现的接口
	channelAPI.Service.IOpenChannel = service
	channelAPI.Service.ICloseChannel = service
	channelAPI.Service.IReport = service
}

func Report(channelName string, data interface{}) {
	report.push(channelName, data)
}

func RebindScriptEngine(channelEntity *channelEntity.SerialChannelEntity, channelParam map[string]interface{}) error {
	return service.rebindScriptEngine(channelEntity, channelParam)
}
